package tokens;

import java.util.ListIterator;
import java.util.Queue;
import java.util.Stack;

import parser.ParserException;

import model.Model;
import nodes.AbstractNode;
import nodes.VariableNode;
import nodes.binary.AssignNode;


/**
 * A token used for assigning values to variables
 * @author Charlie Hatcher
 * @author Roman Zhang
 */
public class AssignToken extends AbstractBinaryToken
{
	private static final String ASSIGNMENT_TOKEN = "\\=";
    public AssignToken ()
    {
        precedence = -1;
    }

	

	@Override
	public AbstractNode process(){
		return new AssignNode(myModel);
	}
	
	@Override
	public boolean matchToken(String str, ListIterator<String> it) {
		return str.matches(ASSIGNMENT_TOKEN);
	}
	
	public String toString(){
		return syntaxBundle.getString("assignment_label");
	}



	@Override
	public void handleParser(String str, ListIterator<String> it,
			Stack<AbstractBinaryToken> opStack,
			Queue<AbstractNode> outPutQueue, Queue<AbstractNode> queue)
			throws Exception {
	        outPutQueue.add(new AssignToken().process());
	}

}